package nl.haemers.data.reflection 
{
	import nl.haemers.data.collections.List;
	import nl.haemers.data.constants.ReflectionConstants;
	/**
	 * ...
	 * @author Jonathan Haemers
	 */
	public class Metadatas implements IMetadatas
	{
		private var _list				:List;
		
		public function Metadatas(description:XML) 
		{
			_list = new List();
			init(description);
		}
		
		/** Public methods **/
		public function getMetadata(name:String) : IMetadata
		{
			return _list.search(name) as IMetadata;
		}
		
		public function hasMetadata(name:String) : Boolean
		{
			return _list.hasKey(name);
		}
		
		/** Getters & Setters **/
		
		/** Protected methods **/
		
		/** Private methods **/
		
		/** Static methods **/
		private function init(xml:XML) : Boolean
		{
			//var metadatas:Metadatas = new Metadatas();
			
			for each(var node:XML in xml.elements(ReflectionConstants.XML_METADATA))
			{
				if (node.@name != "__go_to_definition_help")
				{
					var metadata:Metadata = new Metadata(node);
					_list.add(metadata.toString(), metadata);
				}
			}
			
			return true;
		}
		
	}

}